package com.archermind.boc.xml.xstream;

import java.util.HashMap;

import com.archermind.boc.domain.BaseDomain;
import com.archermind.boc.domain.BaseMedia;
import com.archermind.boc.domain.Content;
import com.archermind.boc.domain.IQ;
import com.archermind.boc.domain.Jingle;
import com.archermind.boc.domain.Register;
import com.archermind.boc.domain.Session;
import com.archermind.boc.domain.Transport;
import com.archermind.boc.domain.Video;
import com.archermind.boc.xml.converter.HashMapConverter;
import com.archermind.boc.xml.converter.TransportConverter;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;

public class IQXStream extends XStream {
	public IQXStream() {
		super(new DomDriver());
		registerConverter(new TransportConverter());
		registerConverter(new HashMapConverter());
		alias("iq", IQ.class);
		alias("jingle", Jingle.class);
		alias("video", Video.class);
		alias("content", Content.class);
		alias("transport", Transport.class);
		alias("session", Session.class);
		alias("register", Register.class);
		alias("x", HashMap.class);
		omitField(BaseDomain.class, "sessionID");
		useAttributeFor(IQ.class, "id");
		useAttributeFor(IQ.class, "to");
		useAttributeFor(IQ.class, "from");
		useAttributeFor(IQ.class, "type");
		useAttributeFor(BaseMedia.class, "action");
		useAttributeFor(BaseMedia.class, "initiator");
		useAttributeFor(BaseMedia.class, "sid");
		useAttributeFor(Content.class, "creator");
		useAttributeFor(Content.class, "name");
		useAttributeFor(Transport.class, "ip");
		useAttributeFor(Transport.class, "port");
	}
}
